<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link href="$!webPath/resources/style/system/manage/$!{config.websiteCss}/template.css"  rel="stylesheet" type="text/css"/>
<link  href="$!webPath/resources/style/common/css/jquery-ui-1.8.22.custom.css" type=text/css rel=stylesheet>
<script src="$!webPath/resources/js/jquery-1.6.2.js"></script>
<script src="$!webPath/resources/js/jquery.validate.min.js"></script>
<script src="$!webPath/resources/js/jquery.shop.common.js"></script>
<script src="$!webPath/resources/js/jquery.poshytip.min.js"></script>
<script src="$!webPath/resources/js/jquery-ui-1.8.21.js"></script>
<script src="$!webPath/resources/js/jquery.zh.cn.js"></script>
<script>
jQuery(document).ready(function(){
  jQuery.validator.methods.endTime = function(value, element, param) {
   var startDate = jQuery(param).val();
   var date1=new Date(Date.parse(startDate));
   var date2=new Date(Date.parse(value));
   if(jQuery.browser.msie==true){
      date1 = new Date(Date.parse(startDate.replace("-", "/")));
      date2 = new Date(Date.parse(value.replace("-", "/")));
   }
   return date1 < date2;
 };
 jQuery.validator.methods.beginTime = function(value, element, param) {
   var endDate = jQuery(param).val();
   var date1=new Date(Date.parse(endDate));
   var date2=new Date(Date.parse(value));
   if(jQuery.browser.msie==true){
      date1 = new Date(Date.parse(endDate.replace("-", "/")));
      date2 = new Date(Date.parse(value.replace("-", "/")));
   }
   return date1 > date2;
 };
  jQuery("#theForm").validate({
	errorPlacement: function(error, element) {  
       error.appendTo(element.parent());  
    },						  
    rules:{
	   coupon_name:{required:true},	
	   coupon_begin_time:{required:true},
	   coupon_end_time:{required:true,endTime:"#coupon_begin_time"},
	   coupon_count:{required:true,digits:true},
	   coupon_amount:{required:true,digits:true,min:0},
	   coupon_order_amount:{required:true,digits:true,min:0}
	 },
    messages:{
	 coupon_name:{required:"优惠券名称不能为空"},		
	 coupon_begin_time:{required:"开始时间不能为空"},
	 coupon_end_time:{required:"结束时间不能为空",endTime:"结束日期必须大于开始日期"},
	 coupon_count:{required:"优惠券数量不能为空",digits:"优惠券只能为整数"},
	 coupon_amount:{required:"优惠券金额不能为空",digits:"优惠券金额只能为整数",min:"优惠券金额必须大于0"},
	 coupon_order_amount:{required:"可使用订单金额不能为空",digits:"可使用订单金额只能为整数",min:"可使用订单金额必须大于0"}
	}
  });
 	//改变系统提示的样式
  jQuery("span .w").mousemove(function(){
	var id=jQuery(this.parentNode).attr("id");
	if(id="nothis"){
	   jQuery(this.parentNode).attr("id","this")
	}
  }).mouseout(function(){
     var id=jQuery(this.parentNode).attr("id");
	 if(id="this"){
	   jQuery(this.parentNode).attr("id","nothis")
	 }
  });
  //
  jQuery('#coupon_begin_time').attr("readonly","readonly").datepicker({
	  dateFormat:"yy-mm-dd",
	  changeMonth: true,
	  changeYear: true
  });
  jQuery('#coupon_end_time').attr("readonly","readonly").datepicker({
	  dateFormat:"yy-mm-dd",
	  changeMonth: true,
	  changeYear: true
  });
  //
  jQuery("#coupon_show").mouseover(function(){
	jQuery("#coupon").css('display','block');
	});
	jQuery("#coupon_show").mouseout(function(){
		jQuery("#coupon").css('display','none');
	});
  //
    jQuery("input[type=file]").change(function(){
	   var id=jQuery(this).attr("id");
	   jQuery("#"+id+"_text").val(jQuery(this).val());
   })
  //
});

function saveForm(){
	jQuery("#theForm").submit();
}
</script>
</head>
<body>
<form action="$!webPath/admin/coupon_save.htm" method="post" enctype="multipart/form-data" name="theForm" id="theForm">
  <div class="cont">
    <h1 class="seth1">新增优惠券</h1>
    <div class="settab"><span class="tab-one"></span> <span class="tabs"> 
	<a href="$!webPath/admin/coupon_list.htm">所有优惠券</a>|<a href="$!webPath/admin/coupon_add.htm" class="this">新增优惠券</a></span> <span class="tab-two"></span></div>
    <div class="setcont" id="base">
      <ul class="set1">
        <li><strong class="orange fontsize20">*</strong>优惠券名称
          <input name="id" type="hidden" id="id" value="$!obj.id" />
        </li>
        <li><span class="webname">
          <input name="coupon_name" type="text" id="coupon_name" value="$!obj.coupon_name" />
          </span></li>
      </ul>
      <ul class="set1">
        <li><strong class="orange fontsize20">*</strong>开始时间</li>
        <li> <span class="webname">
          <input name="coupon_begin_time" type="text" id="coupon_begin_time" value="$!obj.coupon_begin_time" size="25" />
        </span></li>
      </ul>
      <ul class="set1">
        <li><strong class="orange fontsize20">*</strong>结束时间</li>
        <li> <span class="webname">
          <input name="coupon_end_time" type="text" id="coupon_end_time" value="$!obj.coupon_end_time" size="25" />
        </span></li>
      </ul>
      <ul class="set1">
        <li><strong class="orange fontsize20">*</strong>优惠券数量</li>
        <li> <span class="webname">
          <input name="coupon_count" type="text" id="coupon_count" value="$!obj.coupon_count" />
        </span><span id="nothis"><strong class="q"></strong><strong class="w">数量为0时表示不限制数量</strong><strong class="c"></strong></span></li>
      </ul>
      <ul class="set1">
        <li>优惠券模板</li>
        <li> <span class="size13" >
          <input name="coupon_img_text" type="text" id="coupon_img_text" />
          </span> <span class="filebtn">
          <input name="button" type="button" id="button1" value=""/>
          </span> <span style="float:left;" class="file">
          <input name="coupon_img" type="file" id="coupon_img" class="file-text" size="30"/>
          </span> <span class="preview"> <img src="$!webPath/resources/style/system/manage/blue/images/preview.jpg" width="25" height="25"  id="coupon_show" style="cursor:help"/> </span> <span id="nothis"><strong class="q"></strong><strong class="w">尺寸:235px * 103px，模板制作参考默认模板信息尺寸及空白区域尺寸，<a href="$!webPath/resources/style/common/template/coupon_template.jpg" target="_blank">点击下载默认模板</a>不选择模板图片将使用默认模板</strong><strong class="c"></strong></span>
          <div class="bigimgpre" id="coupon" style="display:none;"><img  src="$!webPath/resources/style/common/images/coupon.jpg" width="235" height="103" /> </div>
        </li>
      </ul>
      <ul class="set1">
        <li><strong class="orange fontsize20">*</strong>优惠券金额</li>
        <li> <span class="webname">
          <input name="coupon_amount" type="text" id="coupon_amount" value="$!obj.coupon_amount" />
        </span></li>
      </ul>
      <ul class="set1">
        <li><strong class="orange fontsize20">*</strong>可使用订单金额</li>
        <li> <span class="webname">
          <input name="coupon_order_amount" type="text" id="coupon_order_amount" value="$!obj.coupon_order_amount" />
        </span><span id="nothis"><strong class="q"></strong><strong class="w">订单金额达到该数值才可使用此优惠券</strong><strong class="c"></strong></span></li>
      </ul>
    </div>
  </div>
  <div class="submit">
    <input name="" type="button" value="保存" style="cursor:pointer;" onclick="saveForm();"/>
  </div>
</form>
</body>
</html>
